<!DOCTYPE html>
<html>
<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>传智健康</title>
    <meta name="description" content="传智健康">
    <meta name="keywords" content="传智健康">
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <!-- 引入样式 -->
    <link rel="stylesheet" href="../plugins/elementui/index.css">
    <link rel="stylesheet" href="../plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="../css/style.css">
</head>
<body class="hold-transition">
<div id="app">
    <div class="content-header">
        <h1>健康评估<small>中医体质辨识</small></h1>
        <el-breadcrumb separator-class="el-icon-arrow-right" class="breadcrumb">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>健康评估</el-breadcrumb-item>
            <el-breadcrumb-item>中医体质辨识</el-breadcrumb-item>
        </el-breadcrumb>
    </div>
    <div class="app-container">
        <div class="box">
            <div class="filter-container">
                <el-input placeholder="档案号/姓名" v-model="pagination.queryString" style="width: 200px;"
                          class="filter-item"></el-input>
                <el-button @click="findPage()" class="dalfBut">查询</el-button>
                <el-button type="primary" class="butT" @click="handleCreate()">新建</el-button>
            </div>
            <el-table size="small" current-row-key="id" :data="dataList" stripe highlight-current-row>
                <el-table-column type="index" align="center" label="序号"></el-table-column>
                <el-table-column prop="fileid" label="档案号" align="center"></el-table-column>
                <el-table-column prop="name" label="姓名" align="center"></el-table-column>
                <el-table-column prop="evaluatedate" label="评估日期" align="center"></el-table-column>

                <el-table-column label="平和质" align="center">
                    <template slot-scope="scope">
                        <span>{{ scope.row.pinghe == '0' ? '否' : '是'}}</span>
                    </template>
                </el-table-column>

                <el-table-column label="气虚质" align="center">
                    <template slot-scope="scope">
                        <span>{{ scope.row.qixu == '0' ? '否' : '是'}}</span>
                    </template>
                </el-table-column>

                <el-table-column label="阳虚质" align="center">
                    <template slot-scope="scope">
                        <span>{{ scope.row.yangxu == '0' ? '否' : '是'}}</span>
                    </template>
                </el-table-column>

                <el-table-column label="阴虚质" align="center">
                    <template slot-scope="scope">
                        <span>{{ scope.row.yinxu == '0' ? '否' : '是'}}</span>
                    </template>
                </el-table-column>

                <el-table-column label="痰湿质" align="center">
                    <template slot-scope="scope">
                        <span>{{ scope.row.tanshi == '0' ? '否' : '是'}}</span>
                    </template>
                </el-table-column>

                <el-table-column label="湿热质" align="center">
                    <template slot-scope="scope">
                        <span>{{ scope.row.shire == '0' ? '否' : '是'}}</span>
                    </template>
                </el-table-column>

                <el-table-column label="血瘀质" align="center">
                    <template slot-scope="scope">
                        <span>{{ scope.row.xueyu == '0' ? '否' : '是'}}</span>
                    </template>
                </el-table-column>

                <el-table-column label="气郁质" align="center">
                    <template slot-scope="scope">
                        <span>{{ scope.row.qiyu == '0' ? '否' : '是'}}</span>
                    </template>
                </el-table-column>

                <el-table-column label="特禀质" align="center">
                    <template slot-scope="scope">
                        <span>{{ scope.row.tebing == '0' ? '否' : '是'}}</span>
                    </template>
                </el-table-column>

                <el-table-column label="操作" align="center">
                    <template slot-scope="scope">
                        <el-button type="primary" size="mini" @click="handleUpdate(scope.row)">编辑</el-button><br/>
                        <el-button size="mini" type="danger" @click="handleDelete(scope.row)">删除</el-button><br/>
                    </template>
                </el-table-column>

                <el-table-column label="查看报告" align="center">
                    <template slot-scope="scope">
                        <el-button type="primary" size="mini" @click="handleUpdate(scope.row)">查看报告</el-button>
                    </template>
                </el-table-column>

            </el-table>
            <div class="pagination-container">
                <el-pagination
                        class="pagiantion"
                        @current-change="handleCurrentChange"
                        :current-page="pagination.currentPage"
                        :page-size="pagination.pageSize"
                        layout="total, prev, pager, next, jumper"
                        :total="pagination.total">
                </el-pagination>
            </div>
            <!-- 新增标签弹层 -->
            <div class="add-form">
                <el-dialog title="新增" :visible.sync="dialogFormVisible">
                    <el-form ref="dataAddForm" :model="formData" :rules="rules" label-position="right"
                             label-width="100px">
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="档案号" prop="fileid">
                                    <el-input v-model="formData.fileid"/>
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                                <el-form-item label="姓名" prop="name">
                                    <el-input v-model="formData.name"/>
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                                <el-form-item label="年龄">
                                    <el-input v-model="formData.age"/>
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                                <el-form-item label="性别">
                                    <el-select v-model="formData.sex">
                                        <el-option label="男" value="1"></el-option>
                                        <el-option label="女" value="0"></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                        </el-row>


                        <el-tabs v-model="activeName" type="card">
                            <!--<el-tab-pane label="检查项信息" name="1">-->
                            <el-tab-pane v-for="c in constitutions" :label="c.name" :name="c.id">
                                <el-row v-for="q in c.question" >
                                    {{q.name}}
                                    <el-select v-model="q.answer" style="float: right">
                                        <el-option label="没有" value="1"></el-option>
                                        <el-option label="很少" value="2"></el-option>
                                        <el-option label="有时" value="3"></el-option>
                                        <el-option label="经常" value="4"></el-option>
                                        <el-option label="总是" value="5"></el-option>
                                    </el-select>
                                </el-row>
                            </el-tab-pane>
                        </el-tabs>

                        </el-row>
                    </el-form>
                    <div slot="footer" class="dialog-footer">
                        <el-button @click="dialogFormVisible = false">取消</el-button>
                        <el-button type="primary" @click="handleAdd()">确定</el-button>
                    </div>
                </el-dialog>
            </div>

            <!-- 编辑标签弹层 -->
            <div class="add-form">
                <el-dialog title="编辑检查组" :visible.sync="dialogFormVisible4Edit">

                </el-dialog>
            </div>
        </div>
    </div>
</div>
</body>
<!-- 引入组件库 -->
<script src="../js/vue.js"></script>
<script src="../plugins/elementui/index.js"></script>
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script src="../js/axios-0.18.0.js"></script>
<script>
    var vue = new Vue({
        el: '#app',
        data: {
            activeName: '1',//添加/编辑窗口Tab标签名称
            pagination: {//分页相关模型数据
                currentPage: 1,//当前页码
                pageSize: 10,//每页显示的记录数
                total: 0,//总记录数
                queryString: null//查询条件
            },
            dataList: [],//当前页要展示的分页列表数据
            formData: {},//表单数据
            constitutions: [],//新增和编辑表单中对应的题目列表数据

            // daan: [],
            // question:[
            //     []
            // ],

            dialogFormVisible: false,//增加表单是否可见
            dialogFormVisible4Edit: false,//编辑表单是否可见
            rules: {//校验规则
                code: [{required: true, message: '档案号为必填项', trigger: 'blur'}],
                name: [{required: true, message: '姓名为必填项', trigger: 'blur'}],
            }
        },
        //钩子函数，VUE对象初始化完成后自动执行
        created() {
            this.findPage();
        },
        methods: {
            //编辑
            handleEdit() {

            },
            //添加
            handleAdd() {
                this.formData.constitutions = this.constitutions;
                axios.post("/constitution/add.do", this.formData).then((res) => {
                    if (res.data.flag) {
                        if (res.data.flag) {
                            this.$message.success("修改成功");
                            this.findPage();
                            this.dialogFormVisible4Edit = false;
                        } else {
                            this.$message.error(res.data.message);
                        }
                    }
                });
            },
            //分页查询
            findPage() {
                axios.post("/constitution/findPage.do", this.pagination).then((res) => {
                    if (res.data.flag) {
                        if (res.data.data.total <= this.pagination.pageSize && this.pagination.currentPage != 1) {
                            this.pagination.currentPage = 1;
                            this.findPage();
                        }
                        this.dataList = res.data.data.list;
                        this.pagination.total = res.data.data.total;
                    }
                });
            },
            // 重置表单
            resetForm() {
                this.formData = {};
                this.$refs['dataAddForm'].resetFields();
            },
            // 弹出添加窗口
            handleCreate() {
                this.dialogFormVisible = true;
                axios.post("/constitution/getquestion.do", this.pagination).then((res) => {
                    if (res.data.flag) {
                        console.log(res.data.data)
                        this.constitutions = res.data.data;
                    }
                });
                this.resetForm();
            },
            // 弹出编辑窗口
            handleUpdate(row) {
                this.dialogFormVisible4Edit = true;
                this.$refs['dataEditForm'].resetFields();
            },
            //切换页码
            handleCurrentChange(currentPage) {
                this.pagination.currentPage = currentPage;
                this.findPage();
            },
            // 删除
            handleDelete(row) {

            }
        }
    })
</script>
</html>